﻿@using CkSoftware.GroupMe.Sdk.TestWeb.Helpers
@model IEnumerable<CkSoftware.GroupMe.Sdk.Core.Dao.GroupMeMessageData>

@{
    ViewBag.Title = "Bot Callback Message List";
}

<div class="page-header">
    <h1>Bot Callback Message List</h1>
</div>

@if (!SessionConfiguration.IsConfigValueIsSet<string>(SessionConfiguration.GroupMeBotApiKeyConfigKey))
{
    <h2>Configuration required</h2>
    <p>Before you can start here, you have to configure your GroupMe API Key @Html.Bootstrap().ActionLink("here", "Index").</p>
}
else
{
    <p>In the following list, all recently received bot-callback messages are available (only for your session):</p>

    using (var table = Html.Bootstrap().Begin(new Table().Striped()))
    {
        using (table.BeginHeader())
        {
            <tr>
                <th>DateTime received</th>
                <th>GroupId</th>
                <th>Message</th>
                <th>Original content</th>
            </tr>
        }
        using (var body = table.BeginBody())
        {
            foreach (var item in Model)
            {
                using (var row = body.BeginRow())
                {
                    @row.Cell(string.Concat(item.Received.ToShortDateString(), " ", item.Received.ToShortTimeString()))
                    @row.Cell(item.GroupId)
                    @row.Cell(item.Text)
                    @row.Cell(item.RawData.Replace("\r\n", "<br />"))
                }
            }
        }
    }
}